polling
Portable interface to epoll, kqueue, event ports, and IOCP.
Supported platforms:
- epoll: Linux, Android
- kqueue: macOS, iOS, tvOS, watchOS, FreeBSD, NetBSD, OpenBSD, DragonFly BSD
- event ports: illumos, Solaris
- poll: VxWorks, Fuchsia, other Unix systems
- IOCP: Windows, Wine (version 7.13+)
Polling is done in oneshot mode, which means interest in I/O events needs to be reset after an event is delivered if we're interested in the next event of the same kind.
Only one thread can be waiting for I/O events at a time.
Examples
use ;
use TcpListener;
// Create a TCP listener.
let socket = bind?;
socket.set_nonblocking?;
let key = 7; // Arbitrary key identifying the socket.
// Create a poller and register interest in readability on the socket.
let poller = new?;
poller.add?;
// The event loop.
let mut events = Vec new;
loop
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.